package jiejie.jianzhioffer;

public class offer05 {
    public static void main(String[] args) {
        String s="you are my super star!";
        System.out.println(replaceSpace(s));
    }
    /**
     * 替换空格
     * @param s
     * @return
     */
    public static String replaceSpace(String s) {
        char[] res = new char[3*s.length()];
        int start=0;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)==' '){
                res[start++]='%';
                res[start++]='2';
                res[start++]='0';
            }
            else
                res[start++]=s.charAt(i);
        }

        return String.valueOf(res).substring(0,start);
    }
}